package com.sunwayworld.basemodule.common.asynctask.comsumer.callback;

import com.sunwayworld.basemodule.common.asynctask.bean.LimsAsynctaskBean;
import com.sunwayworld.cloud.module.email.service.CoreEmailService;
import com.sunwayworld.framework.spring.annotation.GikamBean;
import com.sunwayworld.framework.utils.BeanUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

//异步任务执行完毕后回调方法,实现发邮件
@Service
@GikamBean
public class EmailTaskExecuteCallback implements TaskExecuteCallback{
    private static final Logger logger = LogManager.getLogger(EmailTaskExecuteCallback.class);
    @Autowired
    private CoreEmailService coreEmailService;

    @Override
    public void callBack(LimsAsynctaskBean asynctaskBean) {
        logger.info("异步任务执行回调,发邮件,任务={},执行完毕,执行结果={},错误信息={}",asynctaskBean.getTaskId(),asynctaskBean.getExecStatus(),asynctaskBean.getErrMsg());
        /*String configId = "T_LIMS_ASYNCTASK";
        List<String> receipentIdList = new ArrayList<>();
        Map<String, Object> replacementContainer = BeanUtils.toMap(asynctaskBean);
        String senderEmail = "null";
        String ccUsersIds [] = null;
        coreEmailService.insert(configId,receipentIdList,replacementContainer,senderEmail,ccUsersIds);*/
    }
}
